Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-close

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-close

gracefully close open sockets in a http server

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.1K
decreased by-20.18%
Maintainers
1
Weekly downloads
 
Created
Source

http-close

http-close keeps track on open sockets and closes them gracefully when the tcp server is closeing.

When you call server.close() this moudule will:

  • Destroy all sockets without a corresponding http response (keep-alive)
  • Send Connection: close to http requests where the headers is not sent
  • Set the socket timeout to the value you specify. Default 5 seconds.

When a socket timeouts after the server is closed, this module will respond with a 500 status code and end the connection where the headers is not sent. All other sockets will be destroyed.

Usage

var http = require('http')
  , httpClose = require('http-close')

var server = http.createServer()

// Add http-close hook
httpClose({ timeout: 2000 }, server)

// Just call server.close as usual when you want to stop the server
server.close()

Install

$ npm install http-close

License

MIT

FAQs

Package last updated on 04 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc